home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr10
/
bagtag2.zip
/
GOTO.CB
< prev
next >
Wrap
Text File
|
1993-03-21
|
3KB
|
120 lines
/****************************************************************************
*
* goto.cb 21Mar93
*
* Pre-processor for goto_line, so that
* Esc kills the command
* entering a numeric string acts just like goto_line
* entering a non-numeric string "foo" acts like tag foo
* entering "+", "-" steps to next, previous function header
* Enter acts like ctag
*
* Contains macros:
* goto
*
* Copyright (c) 1992 B. Goldstein -- Pequod Software
*
* Change History (see also individual entries):
* Date Who What
* ------- --- -------------
* 17Nov92 BAG First draft
* 19Nov92 BAG Trim leading and trailing blanks from arg
* 21Nov92 BAG Add "-" and "+" to go to prior, subsequent function header
* 25Nov92 BAG Dropped cbrief.h for distribution
* 29Nov92 BAG Trim arg before checking it
* 21Mar93 BAG If shift key down, do goto column
*
****************************************************************************/
/* Definitions */
#include <cbrief.h>
/***************************************************************************/
/* Externals */
void ctag (void);
void tag (~string);
void center_line (void);
/***************************************************************************/
int goto (~string)
{ string _goto_arg;
global _goto_arg;
int retcode;
/*═════════════════════════════════*/
/* First, see if "modified goto" */
/*═════════════════════════════════*/
if ((inq_kbd_flags () & (LEFT_SHIFT | RIGHT_SHIFT)))
{ int col;
if (get_parm (0, col, "Go to column: ") <= 0 || col == 0)
return (0);
move_abs (NULL, col);
return (1);
}
/*══════════════════════*/
/* "Un-modified" goto */
/*══════════════════════*/
// Esc ==> get out
if (get_parm (0, _goto_arg,
"Go to line, function, or tag: ", NULL, _goto_arg) <= 0)
return (0);
_goto_arg = ltrim (trim (_goto_arg));
// No arg ==> ctag
if (strlen (_goto_arg) == 0)
{ ctag ();
return (1);
}
// Numeric arg ==> old goto_line
if (index ("0123456789", substr (_goto_arg, 1, 1)) != 0)
return (goto_line (atoi (_goto_arg)));
// search for a function definition
if (_goto_arg == "+" || _goto_arg == "-")
{ save_position ();
if (_goto_arg == "+")
{ next_char ();
retcode = search_fwd ("<[A-Za-z_.][~;\n]@([~;]@>");
}
else
{ prev_char ();
retcode = search_back ("<[A-Za-z_.][~;\n]@([~;]@>");
}
if (retcode <= 0)
{ restore_position (1);
message ("No %s function.",
((_goto_arg == "+") ? "next" : "prev"));
return (0);
}
else
{ restore_position (0);
center_line ();
message ("Found %s function.",
((_goto_arg == "+") ? "next" : "prev"));
return (1);
}
}
// Tag to explicit argument
tag (_goto_arg);
return (1);
}
/************************* end of goto.cb file *****************************/